/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticks.PID.subsystems;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.PIDController;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
 *
 * @author Jared
 */
public class VelocityControl extends Subsystem implements PIDOutput{
    private PIDController pid;
    private Encoder encoder;
    private Jaguar jaguar;
    public VelocityControl(){
        encoder = new Encoder(1, 2);
        jaguar = new Jaguar(1);
        encoder.setDistancePerPulse(0.01);//set this normally
        encoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kRate);
        pid = new PIDController(1, 0.1, 0.02, encoder, this);//set/tune your pid gains as normal
        pid.setOutputRange(0.03, -0.03); //For our shooter, these values worked well with the default 50 ms loop time for the pid loop
        //They work even though the jaguar range is 1 to -1 because 0.03 gets added to itself many times
    }

    public void initDefaultCommand() {
    }

    public void pidWrite(double output) {
        jaguar.set(jaguar.get()+output);
    }
}
